**** Project: Who Accepts Party Policy Change? The Individual-Level Determinants of Policy Change Acceptance
**** Authors: Maurits J. Meijers & Ruth Dassonneville
**** File Info: Analyses for replication 
**** Date: January 22, 2024

***************************************
*** Open Data ***
***************************************

*Set folder
cd "/Users/maurits.meijers/Dropbox/academic/research/Veni_Projects/Projects/PolicyChange_Acceptance/replication/"
cd "~/Dropbox/PolicyChange_Acceptance/replication"

use data/main_data.dta, clear

log using log.log, replace

***************************************
*** Analyses In Manuscript ***
***************************************

**** Figure 1: Density plot ****

* Install package for grouped density plot1opt:
ssc install multidensity

multidensity gen change_accept , by(country2) min(1) max(7)
 multidensity juxta, recast(area)  opt1(lcolor(navy) color(navy%40)) opt5(lcolor(dkorange) color(dkorange%40)) opt3(lcolor(emerald) color(emerald%40))  opt2(lcolor(cranberry) color(cranberry%40)) opt4(lcolor(gs5) color(gs5%40))  title("") xsc(r(1 7)) xla(1(1)7) ysc(r(0 .4)) yla(0(0.05).4) 

** ALt Fig 1: Histograms

twoway (histogram change_accept if country2==1, percent color(navy%40) xline(4.49, lpattern(dash)) width(1)), ///        
        xtitle("Germany") xsc(r(1 7)) xla(1(1)7) title("") text(36.5 5.2 "x̄ = 4.49", size(small) color(gray)) saving(hist_1.gph, replace)
		
twoway (histogram change_accept if country2==2, percent color(cranberry%40)  xline(4.20, lpattern(dash)) width(1)), ///        
        xtitle("Poland") xsc(r(1 7)) xla(1(1)7) title("")  text(36.5 4.9 "x̄ = 4.20", size(small) color(gray)) saving(hist_2.gph, replace)

twoway (histogram change_accept if country2==3, percent color(emerald%40) xline(4.08, lpattern(dash)) width(1)), ///        
        xtitle("Spain") xsc(r(1 7)) xla(1(1)7) title("")  text(36.5 4.8 "x̄ = 4.08", size(small) color(gray))  saving(hist_3.gph, replace)
		
twoway (histogram change_accept if country2==4, percent color(gs5%40) xline(4.55, lpattern(dash)) width(1)), ///        
        xtitle("The Netherlands") xsc(r(1 7)) xla(1(1)7)  title("") text(36.5 5.25 "x̄ = 4.55", size(small) color(gray)) saving(hist_4.gph, replace)
		
twoway (histogram change_accept if country2==5, percent color(dkorange%40) xline(4.83, lpattern(dash)) width(1)), ///        
        xtitle("United Kingdom") xsc(r(1 7)) xla(1(1)7) title("") text(36.5 5.6 "x̄ = 4.83", size(small) color(gray)) saving(hist_5.gph, replace)
	  
graph combine hist_1.gph hist_2.gph hist_3.gph hist_4.gph hist_5.gph, ycommon 
	    
 
 
**** Table 3: Pooled OLS regression analysis ****
reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb i.country [pweight=weight]
estimates store pooled

* Install package for estimates export
ssc install estout

esttab pooled using main_model.tex, b(3) se(3)  wide label replace drop(*.gender age  *.education_levels_comb *.country) 
esttab pooled using main_model_full.tex, b(3) se(3) r2  wide label replace 

**** Marginal effects of pooled model ****
margins, at(pol_interest=(1 5))
margins, at(extremism=(0 5))
margins, at(technocracy_factor=(-2.75 1.47))
margins, at(popatt_factor=(-2.74 1.44))

**** Standardized coefficients ****
reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb i.country [pweight=weight], beta
estimates store pooled

esttab pooled using main_model_beta.tex, b(3) se(3) beta  wide label replace drop(*.gender age  *.education_levels_comb *.country) 

****  Errors-in-variables analyses ****
eivreg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb i.country  , reliab(pol_interest .9 technocracy_factor .9 extremism .9 popatt_factor .9)
estimates store pooled

esttab pooled using main_model_eivreg.tex, b(3) se(3)  wide label replace drop(*.gender age  *.education_levels_comb *.country) 

**** Figure 2: Coefficient plot per country ****
estimates clear

reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age  i.education_levels_comb [pweight=weight] if country == 1
estimates store de
 reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age  i.education_levels_comb [pweight=weight] if country == 2
estimates store uk
 reg change_accept   pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb [pweight=weight] if country == 3
estimates store es
 reg change_accept   pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb [pweight=weight] if country == 4
estimates store pl
 reg change_accept   pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb [pweight=weight] if country == 5
estimates store nl

set scheme plotplain

* Install package for coefficient plot
ssc install coefplot, replace

coefplot de pl es nl uk, drop(_cons  *.gender age *.education_levels_comb *.country) xline(0)  yscale(lstyle(none)) legend(position(6) rows(2)) coeflabels(,labsize(2.5)) xlabel(, labsize(vsmall)) msize(small)  xsize(4) ysize(4) ///
	 p1(label(Germany) mcolor(navy%70) msymbol(S) )       ///
	 p2(label(Poland) mcolor(cranberry%70) msymbol(O) ) ///
	 p3(label(Spain) mcolor(emerald%70) msymbol(T) )       ///
	 p4(label(Netherlands) mcolor(gs5%70) msymbol(+) )        ///
	 p5(label(United Kingdom) mcolor(dkorange%70) msymbol(D) )   
	 
esttab  de uk es pl nl using models_per_country.tex, b(3) se(3) r2 nomtitle label replace 

**** Figure 3: Coefficient plot left-right extremism ****
estimates clear
reg change_accept extremism_left extremism_right pol_interest technocracy_factor popatt_factor i.gender age  i.education_levels_comb i.country [pweight=weight]
estimates store pooled

reg change_accept extremism_left extremism_right pol_interest technocracy_factor popatt_factor i.gender age  i.education_levels_comb if country == 1 [pweight=weight]
estimates store de

reg change_accept extremism_left extremism_right pol_interest technocracy_factor popatt_factor i.gender age  i.education_levels_comb if country == 2 [pweight=weight]
estimates store uk

reg change_accept extremism_left extremism_right pol_interest technocracy_factor popatt_factor i.gender age  i.education_levels_comb if country == 3 [pweight=weight]
estimates store es

reg change_accept extremism_left extremism_right pol_interest technocracy_factor popatt_factor i.gender age  i.education_levels_comb if country == 4 [pweight=weight]
estimates store pl

reg change_accept extremism_left extremism_right pol_interest technocracy_factor popatt_factor i.gender age  i.education_levels_comb if country == 5 [pweight=weight]
estimates store nl

coefplot pooled de pl es nl uk, keep(extremism_left extremism_right) xline(0)  yscale(lstyle(none)) legend(position(6) rows(2)) coeflabels(,labsize(2.5)) xlabel(, labsize(vsmall)) msize(small)  xsize(4) ysize(4) ///
     p1(label(Pooled) mcolor(black) msymbol(X) )       ///
	 p2(label(Germany) mcolor(navy%70) msymbol(S) )       ///
	 p3(label(Poland) mcolor(cranberry%70) msymbol(O) ) ///
	 p4(label(Spain) mcolor(emerald%70) msymbol(T) )       ///
	 p5(label(Netherlands) mcolor(gs5%70) msymbol(+) )        ///
	 p6(label(United Kingdom) mcolor(dkorange%70) msymbol(D) ) 
	 
esttab pooled de uk es pl nl using extremism_full_models.tex, b(3) se(3) nomtitle label replace
	 
**** Figure 4: Marginal effects plot per preferred party ****
reg change_accept i.preferred_party_de [pweight=weight]
margins preferred_party_de 
marginsplot, recast(bar) title("Germany") ytitle("Policy Change Acceptance") xlabel(,angle(300)) xtitle("") xscale(lstyle(none)) plot1opts(bcolor(navy)) ciopt(color(gs4)) ysc(r(2.5 5.5)) yla(2.5(0.5)5.5) saving(de, replace) 

reg change_accept i.preferred_party_uk [pweight=weight]
margins preferred_party_uk 
marginsplot, recast(bar) title("United Kingdom") ytitle("Policy Change Acceptance") xlabel(,angle(300)) xtitle("") xscale(lstyle(none)) plot1opts(bcolor(dkorange)) ciopt(color(gs4)) ysc(r(2.5 5.5)) yla(2.5(0.5)5.5) saving(uk, replace)

reg change_accept i.preferred_party_es [pweight=weight]
margins preferred_party_es 
marginsplot, recast(bar) title("Spain") ytitle("Policy Change Acceptance") xlabel(,angle(300)) xtitle("") xscale(lstyle(none)) plot1opts(bcolor(emerald)) ciopt(color(gs4)) ysc(r(2.5 5.5)) yla(2.5(0.5)5.5) saving(es, replace)

reg change_accept i.preferred_party_pl [pweight=weight]
margins preferred_party_pl 
marginsplot, recast(bar) title("Poland") ytitle("Policy Change Acceptance") xlabel(,angle(300)) xtitle("") xscale(lstyle(none)) plot1opts(bcolor(cranberry)) ciopt(color(gs4)) ysc(r(2.5 5.5)) yla(2.5(0.5)5.5) saving(pl, replace)

reg change_accept i.preferred_party_nl [pweight=weight]
margins preferred_party_nl 
marginsplot, recast(bar) title("the Netherlands") ytitle("Policy Change Acceptance") xlabel(,angle(300)) xtitle("") xscale(lstyle(none)) plot1opts(bcolor(gs5)) ciopt(color(gs4)) ysc(r(2.5 5.5)) ysize(1) xsize(6) yla(2.5(0.5)5.5) saving(nl, replace)

graph combine de.gph pl.gph es.gph nl.gph uk.gph, saving(comb_party_nl2, replace) 

***************************************
**** Analyses in Appendix ****
***************************************

**** Section C: EFAs ****

**** Table C.1 Pooled Technocratic attitudes EFA ****
factor  tec1 tec2 tec3 tec4, ipf mineigen(1) 
**** Table C.2 Pooled Populist attitudes EFA ****
factor pop1_2-pop6_2, ipf mineigen(1)

**** Table C.3 Technocratic attitudes EFA per country ****
factor  tec1 tec2 tec3 tec4 if country == 1, ipf mineigen(1) 
factor  tec1 tec2 tec3 tec4 if country == 2, ipf mineigen(1) 
factor  tec1 tec2 tec3 tec4 if country == 3, ipf mineigen(1) 
factor  tec1 tec2 tec3 tec4 if country == 4, ipf mineigen(1) 
factor  tec1 tec2 tec3 tec4 if country == 5, ipf mineigen(1) 

**** Table C.4 Technocratic attitudes EFA per country ****
factor  pop1_2-pop6_2 if country == 1, ipf mineigen(1) 
factor  pop1_2-pop6_2 if country == 2, ipf mineigen(1) 
factor  pop1_2-pop6_2 if country == 3, ipf mineigen(1) 
factor  pop1_2-pop6_2 if country == 4, ipf mineigen(1) 
factor  pop1_2-pop6_2 if country == 5, ipf mineigen(1) 

**** Section D: Summary statistics ****

**** Pooled ****
estpost summarize change_accept  pol_interest technocracy_factor extremism popatt_factor gender age education_levels_comb if change_accept != . & pol_interest  != . & technocracy_factor != . & extremism != . & popatt_factor != . & gender != . & age != . & education_levels_comb != .
esttab using sum_stat_pooled.tex, cells("count mean sd min max") noobs label 

****Germany ****
estpost summarize change_accept  pol_interest technocracy_factor extremism popatt_factor gender age education_levels_comb if country == 1 & change_accept != . & pol_interest  != . & technocracy_factor != . & extremism != . & popatt_factor != . & gender != . & age != . & education_levels_comb != .
esttab using sum_stat_de.tex, cells("count mean sd min max") noobs label 

**** UK ****
estpost summarize change_accept  pol_interest technocracy_factor extremism popatt_factor gender age education_levels_comb if country == 2 & change_accept != . & pol_interest  != . & technocracy_factor != . & extremism != . & popatt_factor != . & gender != . & age != . & education_levels_comb != .
esttab using sum_stat_uk.tex, cells("count mean sd min max") noobs label 

**** Spain ****
estpost summarize change_accept  pol_interest technocracy_factor extremism popatt_factor gender age education_levels_comb if country == 3 & change_accept != . & pol_interest  != . & technocracy_factor != . & extremism != . & popatt_factor != . & gender != . & age != . & education_levels_comb != .
esttab using sum_stat_es.tex, cells("count mean sd min max") noobs label 

**** Poland ****
estpost summarize change_accept  pol_interest technocracy_factor extremism popatt_factor gender age education_levels_comb if country == 4 & change_accept != . & pol_interest  != . & technocracy_factor != . & extremism != . & popatt_factor != . & gender != . & age != . & education_levels_comb != .
esttab using sum_stat_pl.tex, cells("count mean sd min max") noobs label 

**** Netherlands ****
estpost summarize change_accept  pol_interest technocracy_factor extremism popatt_factor gender age education_levels_comb if country == 5 & change_accept != . & pol_interest  != . & technocracy_factor != . & extremism != . & popatt_factor != . & gender != . & age != . & education_levels_comb != .
esttab using sum_stat_nl.tex, cells("count mean sd min max") noobs label 

**** Section E: Models controlling for DKs ****
estimates clear

reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb change_accept_dk pol_interest_dk technocracy_dk extremism_dk popatt_dk i.country  [pweight=weight]
estimates store pooled

reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb change_accept_dk pol_interest_dk technocracy_dk extremism_dk popatt_dk if country == 1 [pweight=weight]
estimates store de

reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb change_accept_dk pol_interest_dk technocracy_dk extremism_dk popatt_dk if country == 2 [pweight=weight]
estimates store uk

reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb change_accept_dk pol_interest_dk technocracy_dk extremism_dk popatt_dk if country == 3 [pweight=weight]
estimates store es

reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb change_accept_dk pol_interest_dk technocracy_dk extremism_dk popatt_dk if country == 4 [pweight=weight]
estimates store pl

reg change_accept  pol_interest technocracy_factor extremism popatt_factor i.gender age i.education_levels_comb change_accept_dk pol_interest_dk technocracy_dk extremism_dk popatt_dk if country == 5 [pweight=weight]
estimates store nl

esttab pooled de uk es pl nl using models_dkcontrol_new.tex, b(3) se(3) r2 nomtitle wide label compress replace 

**** Section H: Populist Attitude items seperately ****

estimates clear

quietly reg change_accept  pol_interest technocracy_factor extremism pop1_2 pop1_2 pop2_2 pop3_2 pop4_2 pop5_2 pop6_2 i.gender age  i.education_levels_comb i.country [pweight=weight] 
estimates store pooled
quietly reg change_accept  pol_interest technocracy_factor extremism pop1_2 pop1_2 pop2_2 pop3_2 pop4_2 pop5_2 pop6_2 i.gender age  i.education_levels_comb [pweight=weight] if country == 1
estimates store de
quietly reg change_accept  pol_interest technocracy_factor extremism pop1_2 pop1_2 pop2_2 pop3_2 pop4_2 pop5_2 pop6_2 i.gender age  i.education_levels_comb [pweight=weight] if country == 2
estimates store uk
quietly reg change_accept   pol_interest technocracy_factor extremism pop1_2 pop1_2 pop2_2 pop3_2 pop4_2 pop5_2 pop6_2 i.gender age i.education_levels_comb [pweight=weight] if country == 3
estimates store es
quietly reg change_accept   pol_interest technocracy_factor extremism pop1_2 pop1_2 pop2_2 pop3_2 pop4_2 pop5_2 pop6_2 i.gender age i.education_levels_comb [pweight=weight] if country == 4
estimates store pl
quietly reg change_accept   pol_interest technocracy_factor extremism pop1_2 pop1_2 pop2_2 pop3_2 pop4_2 pop5_2 pop6_2 i.gender age i.education_levels_comb [pweight=weight] if country == 5
estimates store nl

set scheme plotplain

coefplot pooled de uk es pl nl, keep(pop1_2 pop1_2 pop2_2 pop3_2 pop4_2 pop5_2 pop6_2) xline(0)  yscale(lstyle(none)) legend(position(6) rows(2)) coeflabels(,labsize(2.5)) xlabel(, labsize(vsmall)) msize(small)  xsize(4) ysize(4) ///
     p1(label(Pooled) mcolor(black) msymbol(X) )       ///
	 p2(label(Germany) mcolor(navy%70) msymbol(S) )       ///
	 p3(label(United Kingdom) mcolor(dkorange%70) msymbol(D) )       ///
	 p4(label(Spain) mcolor(emerald%70) msymbol(T) )       ///
	 p5(label(Poland) mcolor(cranberry%70) msymbol(O) ) ///
	 p6(label(Netherlands) mcolor(gs5%70) msymbol(+) )     

*** Additional Analyses for R&R


factor pop1_2-pop5_2, ipf mineigen(1)
rotate, blanks(.5) orthogonal varimax
predict popatt_5item_factor
label var popatt_5item_factor "Populist Attitudes (without POP6)"	 


estimates clear

quietly reg change_accept  pol_interest technocracy_factor extremism popatt_5item_factor i.gender age  i.education_levels_comb i.country [pweight=weight] 
estimates store pooled
quietly reg change_accept  pol_interest technocracy_factor extremism popatt_5item_factor i.gender age  i.education_levels_comb [pweight=weight] if country == 1
estimates store de
quietly reg change_accept  pol_interest technocracy_factor extremism popatt_5item_factor i.gender age  i.education_levels_comb [pweight=weight] if country == 2
estimates store uk
quietly reg change_accept   pol_interest technocracy_factor extremism popatt_5item_factor i.gender age i.education_levels_comb [pweight=weight] if country == 3
estimates store es
quietly reg change_accept   pol_interest technocracy_factor extremism popatt_5item_factor i.gender age i.education_levels_comb [pweight=weight] if country == 4
estimates store pl
quietly reg change_accept   pol_interest technocracy_factor extremism popatt_5item_factor i.gender age i.education_levels_comb [pweight=weight] if country == 5
estimates store nl

set scheme plotplain

coefplot pooled de uk es pl nl,  keep(popatt_5item_factor) xline(0)  yscale(lstyle(none)) legend(position(6) rows(2)) coeflabels(,labsize(2.5)) xlabel(, labsize(vsmall)) msize(small)  xsize(4) ysize(4) ///
     p1(label(Pooled) mcolor(black) msymbol(X) )       ///
	 p2(label(Germany) mcolor(navy%70) msymbol(S) )       ///
	 p3(label(United Kingdom) mcolor(dkorange%70) msymbol(D) )       ///
	 p4(label(Spain) mcolor(emerald%70) msymbol(T) )       ///
	 p5(label(Poland) mcolor(cranberry%70) msymbol(O) ) ///
	 p6(label(Netherlands) mcolor(gs5%70) msymbol(+) )     
	 

	 
log close
